package cn.tedu.tmall.admin.mall.service.impl;

import cn.tedu.tmall.admin.mall.dao.persist.repository.IOrderRepository;
import cn.tedu.tmall.admin.mall.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class OrderServiceImpl implements IOrderService {
    @Value("${tmall.order.pay-over-in-minute}")
    private int payOverInMinute;
    @Autowired
    private IOrderRepository repository;
    @Override
    public int closeUnpaid() {
        log.debug("开始处理[超时未支付的订单]的业务");
        List<Long> idList = repository.listOverTimeUnPaidOrderId(payOverInMinute);
        int rows = repository.updateStateByBatchIds(idList, ORDER_STATE_CLOSED_BY_SYSTEM);
        log.debug("成功关闭[超时未支付的订单]");
        return rows;
    }
}
